<?php
namespace Admin\Controller;
use Think\Controller;
class AnswerController extends CommonController {
    public function index(){
    	$w=I('get.w','','intval');
		switch ($w) {
			case 0:
				$where=null;
				break;
			case 1:
				$where=array('adopt'=>0);
				break;
			case 2:
				$where=array('adopt'=>1);
				break;
			default:	
				break;
		}
		$field='anid,content,time';
		$db=M('answer');
		$count=$db->where($where)->count();
		$this->assign('count',$count);
		//调用function.php的getpage获取分页函数，简化分页
		$page=getpage($count,10);
		$answer=$db->field($field)->where($where)->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('page',$page->show());
		$this->assign('answer',$answer);
    	$this->display('answer');
    }
	public function del_answer(){
		$anid=I('get.anid','','intval');
		$db=M('answer')->where(array('anid'=>$anid))->delete();
		if($db){
			$this->success('删除成功');
		}
	}
}